import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Arrays;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Home-pc
 * Date: 2023-08-26
 * Time: 13:48
 */
public class TestSort {
    public static void notOrderArray(int[] array){
        Random random=new Random();
        for (int i = 0; i < array.length; i++) {
            array[i]=random.nextInt(100);
        }
    }
    public static void testShellSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        Sort.shellSort(array);
        System.out.println(Arrays.toString(array));
    }

    public static void testSelectSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        Sort.selectSort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void testSelectSort2(int[] array){
        array=Arrays.copyOf(array,array.length);
        Sort.selectSort2(array);
        System.out.println(Arrays.toString(array));
    }
    public static void testheapSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        Sort.heapSort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void testbubbleSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        Sort.bubbleSort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void testquickSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        //long startTime=System.currentTimeMillis();
        Sort.quickSort(array);
        //long endTime=System.currentTimeMillis();
        System.out.println(Arrays.toString(array));
        //System.out.println("优化后排序时间"+(endTime-startTime));
    }
    public static void testquickSortByStack(int[] array){
        array=Arrays.copyOf(array,array.length);
        //long startTime=System.currentTimeMillis();
        Sort.quickSortByStack(array);
        //long endTime=System.currentTimeMillis();
        System.out.println(Arrays.toString(array));
        //System.out.println("优化后排序时间"+(endTime-startTime));
    }
    public static void testmergeSort(int[] array){
        array=Arrays.copyOf(array,array.length);
        //long startTime=System.currentTimeMillis();
        Sort.mergeSort(array);
        //long endTime=System.currentTimeMillis();
        System.out.println(Arrays.toString(array));
        //System.out.println("优化后排序时间"+(endTime-startTime));
    }


    public static void testcountArray(int[] array){
        array=Arrays.copyOf(array,array.length);
        //long startTime=System.currentTimeMillis();
        Sort.countArray(array);
        //long endTime=System.currentTimeMillis();
        System.out.println(Arrays.toString(array));
        //System.out.println("优化后排序时间"+(endTime-startTime));
    }


    public static void main(String[] args) {
        int[] array=new int[30];
        notOrderArray(array);

        System.out.println(Arrays.toString(array));
        testShellSort(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testSelectSort(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testSelectSort2(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testheapSort(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testbubbleSort(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testquickSort(array);

        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testquickSortByStack(array);
        System.out.println("我是分割线");
        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testmergeSort(array);

        System.out.println("我是分割线");
        notOrderArray(array);
        System.out.println(Arrays.toString(array));
        testcountArray(array);

    }
}
